package com.midea.ai.air.ui.more;

import android.app.Activity;
import android.app.Dialog;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.midea.ai.air.R;
import com.midea.ai.air.common.BaseActivity;
import com.midea.ai.air.ui.more.adapter.MoreLoggingAdapter;
import com.midea.ai.air.ui.more.data.MoreLoggingItem;
import com.midea.ai.air.view.ListViewForScrollView;
import com.midea.ai.air.view.MyTitleBar;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by hww on 2016/3/24.
 * 更多-设置-开关日志
 */
public class MoreSettingLocationOnOffLogging extends BaseActivity implements View.OnClickListener {

    private TextView actionbar_left_tv;
    private List<MoreLoggingItem> mList_dates = new ArrayList<>();
    private ListViewForScrollView mListView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_moresettinglocationonofflogging);

        init();
    }

    MyTitleBar myTitleBar;

    private void init() {
        myTitleBar = new MyTitleBar(this);
        myTitleBar.setActionBar_center(R.string.more_setting_location_logging);
        myTitleBar.setActioBar_left(true, R.drawable.register_titler_left, R.string.more_setting_location);
        myTitleBar.setActionBar_right_iv(true, R.drawable.more_logging_delete);

        actionbar_left_tv = (TextView) findViewById(R.id.actionbar_tv_left);
        actionbar_left_tv.setTextColor(getResources().getColor(R.color.electric_histogram));
        create_Delete_Logging_Dialog();
        mListView = (ListViewForScrollView) findViewById(R.id.more_setting_location_on_off_logging_listView);

        mList_dates.add(new MoreLoggingItem(R.drawable.more_setting_location_a, "距离到家还剩下10分钟", "2015年12月30日 20:00  空气管家开始运行"));
        mList_dates.add(new MoreLoggingItem(R.drawable.more_setting_location_b, "已经离家10分钟", "2015年12月30日 20:00  空气管家关闭"));

        mListView.setAdapter(new MoreLoggingAdapter(MoreSettingLocationOnOffLogging.this, mList_dates));

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.actionbar_left_relativeLayout:

                finish();
                break;
            case R.id.actionbar_iv_right:
                delete_Dialog.show();
                break;
        }
    }

    private Dialog delete_Dialog;

    private void create_Delete_Logging_Dialog() {
        View view_delete_logging = LayoutInflater.from(MoreSettingLocationOnOffLogging.this)
                .inflate(R.layout.dialog_delete_logging_item, null);
        delete_Dialog = new Dialog(MoreSettingLocationOnOffLogging.this, R.style.my_activate_dialog);
        delete_Dialog.setCancelable(true);
        delete_Dialog.setCanceledOnTouchOutside(false);
        delete_Dialog.setContentView(view_delete_logging);
        TextView dialog_cancel = (TextView) view_delete_logging.findViewById(R.id.dialog_delete_logging_item_cancel);
        TextView dialog_confirm = (TextView) view_delete_logging.findViewById(R.id.dialog_delete_logging_item_confirm);
        dialog_cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (delete_Dialog != null && delete_Dialog.isShowing()) {
                    delete_Dialog.dismiss();
                }
            }
        });
        dialog_confirm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (delete_Dialog != null && delete_Dialog.isShowing()) {
                    delete_Dialog.dismiss();
                }
            }
        });
    }

}
